<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/component/commonTagLib.jsp"%>

<!DOCTYPE html>
<html>
<head>
    <title><spring:message code="message.lable.drugqualityspecSeeStd"/></title>
    <%@ include file="/WEB-INF/component/commonCSS.jsp"%>
    <!--[if lt IE 9]>
        <script src="${ctx}/lib/js/html5shiv.min.js"></script>
        <script src="${ctx}/lib/js/respond.min.js"></script>
    <![endif]-->
</head>
<body class="skin-blue-light sidebar-mini fixed skin-blue-light-frame">
                            
    <section class="content-header">
        <h1>按医院统计</h1>
        <ol class="breadcrumb">
            <li><a href="${ctx}/home.jsp"><i class="fa fa-home"></i><spring:message code="message.lable.first"/></a></li>
            	<li><a href="#">交易</a></li>
                <li><a href="#">统计与查询</a></li>
                <li><a href="#">按医院统计</a></li>
        </ol>
    </section>
        
    <section class="content">
    	<div class="box box-success">
    		<div class="box-header with-border">
    			<h3 class="box-title" id="chartTitle"></h3>
                <div class="box-tools pull-right">
                    <button class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
                </div><!-- /.box-tools -->
            </div>
            <div class="box-body mchart">
                <div id="mChart" style="height: 300px; width:98%; padding: 8px;"></div>
            </div>
        </div>
        
        <div class=" box box-success">
            <div class="box-body">
             <form  id="form" method="post">
                <div class="input">
                	<div class="textalign">医疗机构名称<spring:message code="message.yanZheng.maoHao"/></div>
                    <div class="boxinput">
                         <input type="text" class="textinput" id="hospName" name="hospName" placeholder="医疗机构名称/<spring:message code="message.listForm.pinYinMa"/>" maxlength="100"  /> 
                    </div>
                    <div class="textalign">统计日期<spring:message code="message.yanZheng.maoHao"/></div>
                    <div class="boxinput">
                    		<table style="width:100%">
                    			<tr>
                    				<td style="width:50%">
                    					<input id="startDate" name="startDate" class="textinput" type="text" readonly placeholder="开始日期"  data-date-fmt="yyyy-MM-dd" onFocus="WdatePicker({maxDate:'#F{$dp.$D(\'endDate\')}'})"/>
                    				</td>
                    				<td>&nbsp;-&nbsp;</td>
                    				<td style="width:50%">
                    					<input id="endDate" name="endDate" class="textinput" type="text" readonly placeholder="结束日期"  data-date-fmt="yyyy-MM-dd" onFocus="WdatePicker({minDate:'#F{$dp.$D(\'startDate\')}'})"/>
                    				</td>
                    			</tr>
                    		</table>
                    </div>
                     <div class="textalign" >
                         <button id="selectSpec" type="button" onclick="search();" class="btn btn-success btn-sm"><spring:message code="message.button.seachSpacing"/></button>
                    </div>
                </div>
            </form>
            </div>
          </div>
        <table class="jqgrid" id="gridlist"></table>
        <div id="gridpage"></div>
        <div class=" box box-warning bottongroup">
			<button type="button" onclick="toYearAnaByHosp();" class="btn btn-primary btn-sm">按年汇总</button>
			<button type="button" onclick="toSeaAnaByHosp ();" class="btn btn-primary btn-sm">按季度汇总</button>
			<button type="button" onclick="toMonthAnaByHosp();" class="btn btn-primary btn-sm">按月汇总</button>
        </div>
    </section>
      <%@ include file="/WEB-INF/component/commonJS.jsp"%>
    <script type="text/javascript">
        $(function () {
        	$('#form :input').bind('keydown', function(event) {if (event.keyCode == "13") {search();}}).eq(0).focus();
            $("#gridlist").jqGrid({
                url: "${ctx}/anaDruginfo/getAnaByHosp.html",
                mtype: "post",
                datatype: "json",
                autowidth: true,
                height: 310,
                colNames: [
					'日期',
                    '医疗机构编码',
                    '医疗机构名称',
                    '医疗机构分类',
                    '采购金额', 
                   	'基药采购金额',
                   	'非基药采购金额',
                   	'基药采购比例',
                    '退货金额',
                    '退货率'
                ],
                colModel: [
					{ name: 'date', width: 100, align:"center", sortable: false},
                    { name: 'hosp_code', width: 140, align:"center", sortable: false},
                    { name: 'hosp_name', width: 200, align:"center", sortable: false,
                    	formatter:function(val,options,rowdata){
                    	 	return "<a href=\"javascript:showHospInfo('" + rowdata.hosp_code + "')\">"+val+"</a>";

                    	}
                    },
                    { name: 'hosp_classify', width: 80, align:"center", sortable: false ,
                    	formatter:function(val){
                    		return val==1?"县级及县级以上医疗机构":"基层医疗机构";
                    	}
                    },
                    { name: 'total_amount', width: 80, align:"center", sortable: false,
                    	formatter:function(val){
                    		return formatAmount(val,null,null);
                    	}
                    },
                    { name: 'base_amount', width: 80, align:"center", sortable: false,
                    	formatter:function(val){return formatAmount(val,null,null);}
                    },
                    { name: 'nonbase_amount', width: 80, align:"center", sortable: false,
                    	formatter:function(val){return formatAmount(val,null,null);}
                    },
                    { name: 'base_ratio', width: 80, align:"center", sortable: false},
                    { name: 'ret_amount', width: 80, align:"center", sortable: false,
                    	formatter:function(val){
                    		return formatAmount(val,null,null);
                    	}
                    },
                    { name: 'ret_ratio', width: 80, align:"center", sortable: false}
                    
                ],
                rowNum: 20,
                rowList: [10, 20, 50,100],
                rownumbers: true,
                pager: "#gridpage",
                multiselect: false, 
                viewrecords: true,
                caption: "按医院统计列表",
                gridComplete:function(){
                    autoRNWidth("gridlist");
                },
                jsonReader: {
                	 repeatitems: false,
                    id: "qualitySpecId"
                },
                loadComplete: function (data) { //完成服务器请求后，回调函数
                	$("#chartTitle").html(data.conditions.chartTitle);
                	var option = {
                        	tooltip: {
                            	trigger: 'axis'
                            },
                                toolbox: {
                                    show: true,
                                    feature: {
                                        mark: { show: true },
                                        dataView: { show: true, readOnly: false },
                                        magicType: { show: true, type: ['line', 'bar'] },
                                        restore: { show: true },
                                        saveAsImage: { show: true }
                                    }
                                },
                                calculable: true,
                                legend: {
                                    data: ['采购金额', '配送金额', '退货金额']
                                },
                                xAxis: [
                                    {
                                        type: 'category',
                                        data: eval(data.conditions.yTime)
                                    }
                                ],
                                yAxis: [
                                    {
                                    	type: 'value',
                                        name: '金额(万元)',
                                        axisLabel: {
                                            formatter: '{value}'
                                        }
                                    }
                                ],
                                series: [

                                    {
                                        name: '采购金额',
                                        type: 'bar',
                                        data: eval(data.conditions.total)
                                    },
                                    {
                                        name: '配送金额',
                                        type: 'bar',
                                        data: eval(data.conditions.del)
                                    },
                                    {
                                        name: '退货金额',
                                        type: 'bar',
                                        data: eval(data.conditions.ret)
                                    }
                                ]
                        };
                    	var myChart = echarts.init(document.getElementById('mChart'), theme);
                        myChart.setOption(option);
                }
            });
            $("#gridlist").jqGrid('navGrid', '#gridpage', { add: false, edit: false, del: false, search: false, refresh: false });
            $(window).trigger("resize");
        });
        function search(page) {
            var data =formatForm("form");
            $("#gridlist").jqGrid('setGridParam',{  
                datatype:'json',
                postData:data,
                page : (page || 1)
            }).trigger("reloadGrid"); //重新载入  
        }
        
        function toYearAnaByHosp(){
        	window.location.href="${ctx}/anaDruginfo/toYearAnaByHosp.html"; 
        }
        
        function toSeaAnaByHosp(){
        	window.location.href="${ctx}/anaDruginfo/toSeaAnaByHosp.html"; 
        }
        
        function toMonthAnaByHosp(){
        	window.location.href="${ctx}/anaDruginfo/toMonthAnaByHosp.html"; 
        }
    </script>
</body>
</html> 
                          
                  
                  